﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdFileDependencyManager : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdFileDependencyManager(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdFileDependencyManager_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdFileDependencyManager obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdFileDependencyManager()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdFileDependencyManager(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdFileDependencyManager cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdFileDependencyManager_cast(OdRxObject.getCPtr(pObj));
			OdFileDependencyManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFileDependencyManager_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFileDependencyManager_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFileDependencyManager_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdFileDependencyManager createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdFileDependencyManager_createObject();
			OdFileDependencyManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFileDependencyManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint createEntry(string feature, string fullFileName, bool affectsGraphics, bool noIncrement)
		{
			uint result = TD_DbPINVOKE.OdFileDependencyManager_createEntry__SWIG_0(this.swigCPtr, feature, fullFileName, affectsGraphics, noIncrement);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint createEntry(string feature, string fullFileName, bool affectsGraphics)
		{
			uint result = TD_DbPINVOKE.OdFileDependencyManager_createEntry__SWIG_1(this.swigCPtr, feature, fullFileName, affectsGraphics);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint createEntry(string feature, string fullFileName)
		{
			uint result = TD_DbPINVOKE.OdFileDependencyManager_createEntry__SWIG_2(this.swigCPtr, feature, fullFileName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getEntry(string feature, string fullFileName, out OdFileDependencyInfo fileInfo, bool useCachedInfo)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_getEntry__SWIG_0(this.swigCPtr, feature, fullFileName, out zero, useCachedInfo);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				fileInfo = (OdFileDependencyInfo)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult getEntry(string feature, string fullFileName, out OdFileDependencyInfo fileInfo)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_getEntry__SWIG_1(this.swigCPtr, feature, fullFileName, out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				fileInfo = (OdFileDependencyInfo)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult getEntry(uint fdlIndex, out OdFileDependencyInfo fileInfo, bool useCachedInfo)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_getEntry__SWIG_2(this.swigCPtr, fdlIndex, out zero, useCachedInfo);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				fileInfo = (OdFileDependencyInfo)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult getEntry(uint fdlIndex, out OdFileDependencyInfo fileInfo)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_getEntry__SWIG_3(this.swigCPtr, fdlIndex, out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				fileInfo = (OdFileDependencyInfo)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult updateEntry(string feature, string fullFileName)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_updateEntry__SWIG_0(this.swigCPtr, feature, fullFileName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult updateEntry(uint index)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_updateEntry__SWIG_1(this.swigCPtr, index);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult eraseEntry(string feature, string fullFileName, bool forceRemove)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_eraseEntry__SWIG_0(this.swigCPtr, feature, fullFileName, forceRemove);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult eraseEntry(string feature, string fullFileName)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_eraseEntry__SWIG_1(this.swigCPtr, feature, fullFileName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult eraseEntry(uint fdlIndex, bool forceRemove)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_eraseEntry__SWIG_2(this.swigCPtr, fdlIndex, forceRemove);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult eraseEntry(uint fdlIndex)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdFileDependencyManager_eraseEntry__SWIG_3(this.swigCPtr, fdlIndex);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint countEntries()
		{
			uint result = TD_DbPINVOKE.OdFileDependencyManager_countEntries(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void iteratorInitialize(string feature, bool modifiedOnly, bool affectsGraphicsOnly, bool walkXRefTree)
		{
			TD_DbPINVOKE.OdFileDependencyManager_iteratorInitialize__SWIG_0(this.swigCPtr, feature, modifiedOnly, affectsGraphicsOnly, walkXRefTree);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void iteratorInitialize(string feature, bool modifiedOnly, bool affectsGraphicsOnly)
		{
			TD_DbPINVOKE.OdFileDependencyManager_iteratorInitialize__SWIG_1(this.swigCPtr, feature, modifiedOnly, affectsGraphicsOnly);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void iteratorInitialize(string feature, bool modifiedOnly)
		{
			TD_DbPINVOKE.OdFileDependencyManager_iteratorInitialize__SWIG_2(this.swigCPtr, feature, modifiedOnly);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void iteratorInitialize(string feature)
		{
			TD_DbPINVOKE.OdFileDependencyManager_iteratorInitialize__SWIG_3(this.swigCPtr, feature);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void iteratorInitialize()
		{
			TD_DbPINVOKE.OdFileDependencyManager_iteratorInitialize__SWIG_4(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual uint iteratorNext()
		{
			uint result = TD_DbPINVOKE.OdFileDependencyManager_iteratorNext(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getFeatures(out OdRxDictionary features)
		{
			IntPtr zero = IntPtr.Zero;
			try
			{
				TD_DbPINVOKE.OdFileDependencyManager_getFeatures(this.swigCPtr, out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				features = (OdRxDictionary)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
		}

		public virtual void clearXRefEntries()
		{
			TD_DbPINVOKE.OdFileDependencyManager_clearXRefEntries(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
